Accusoft.PdfXpress6.ActiveX
Create, Modify & Delete Annotations

PDF Xpress™ provides the capability to export PDF annotations to an XFDF file (ExportXfdf). The application may then read, modify, and write annotations to the XFDF file. When the application calls ImportXfdf, these modifications are applied to the annotations within the PDF document. 

NotateXpress may be used in conjunction with PDF Xpress to provide programmatic or application end-user annotation capabilities.

PDF Xpress supports a subset of PDF native annotation:

PDF Xpress creates XFDF that complies with the published XML Schema:  http://partners.adobe.com/public/developer/en/xml/xfdf.xsd

However, PDF Xpress created XFDF will contain only data for PDF Xpress supported annotations.  

For more information on PDF Xpress support of XFDF elements and attributes, see Frequently Asked Questions: http://www.accusoft.com/pdfxpressfaq.htm.

Read Annotations from a PDF File

Annotations can be retrieved from a PDF document by calling the ExportXfdf method. This method writes PDF annotations from the PDF document into an XFDF file. 

VB Example
Copy Code
'This code demonstrates how to export annotations from a single-page PDF document 
On Error GoTo error
Dim pdfXpress1 As  New PdfXpress
pdfXpress1.Initialize
pdfxpress1.RaiseExceptions = True
Dim document As New PdfDocument
document. SetParentControl pdfXpress1  
document.OpenDocument strFileName, ""
Dim xfdfoptions As New xfdfoptions
xfdfoptions.CanCreateAnnotations = True
xfdfoptions.CanDeleteAnnotations = True
xfdfoptions.WhichAnnotation = -1
xfdfoptions.WhichPage = 0
Dim xml As String
xml = document.ExportXFDF(xfdfoptions)  
xml = Replace(xml, "UTF-16", "UTF-8")
Dim objStream As Object
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Position = 0
objStream.Charset = "UTF-8"
objStream.WriteText xml
objStream.SaveToFile “C:\sample.xfdf”
.
.
.
GoTo finish
error:
MsgBox Err.Description
finish:

Set document = Nothing
pdfxpress1.Terminate
Set pdfxpress1= Nothing

Write Annotations to a PDF File

Annotations can be written to a PDF document by calling the ImportXfdf method. This method takes an XFDF file as input, and stores the annotations as part of the PDF document.

VB Example
Copy Code
'This code demonstrates how to write annotations 
On Error GoTo error
Dim pdfXpress1 As New PdfXpress
pdfXpress1.Initialize
pdfxpress1.RaiseExceptions = True
Dim document As New PdfDocument 
document.SetParentControl pdfxpress1
document.OpenDocument "C:\test.pdf",""
Dim xfdfoptions As New xfdfoptions
xfdfoptions.CanCreateAnnotations = True
Dim strSourceXfdf As String
Dim SizeInBytes As Long
SizeInBytes = FileLen("C:\many21.xfdf")
Dim bom() As Byte
Dim buffer() As Byte
Dim fid As Integer
fid = FreeFile  
Open "C:\\many21.xfdf" For Binary Access Read As fid
bom = InputB(2, fid)
Const WILL_STRIP_BYTEORDERMARK As Boolean = True   
If WILL_STRIP_BYTEORDERMARK _
And ((&HFF = bom(0) And &HFE = bom(1)) _
Or (&HFE = bom(0) Or &HFF = bom(1))) Then
strSourceXfdf = InputB(SizeInBytes - 2, fid)
Else
        Seek #fid, 1
        strSourceXfdf = InputB(SizeInBytes, fid)
End If
Erase bom
Close fid
document.ImportXfdf  xfdfOptions, strSourceXfdf
.
.
.
GoTo finish
error:
MsgBox Err.Description
finish:

Set document = Nothing
pdfxpress1.Terminate
Set pdfxpress1= Nothing

 

See Also

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback